<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>固定定位</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        div{
            width: 200px;
            height: 100px;
        }
        #d1{
            background: red;
            position: fixed;
            z-index: 1;
            left: 100px;
            top: 200px;
        }
        #d2{
            background: green;
            position: fixed;
            left: 200px;
            top: 100px;
            z-index: 2;
        }
        #d3{
            background: blue;
            position: fixed;
            left: 400px;
            /*top: 0px;*/
            bottom: 0px; /* 同时设置左与右或者上与下的偏移时,只有左和上会生效*/
            z-index: 3;
        }
        #d{
            width: 1000px;
            height: 1000px;
            border: #000000 1px solid;
            position: absolute;
            left: 100px;
            top: 100px;
        }
    </style>
</head>
<body>
<div id="d">
    <div id="d1"></div>
    <div id="d2"></div>
    <div id="d3"></div>
</div>

</body>
</html>